package org.example.route.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.route.model.dto.LoginDTO;
import org.example.route.model.dto.RegisterDTO;
import org.example.route.model.dto.UserQueryDTO;
import org.example.route.model.pojo.User;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from user where account = #{account} and password = #{password}")
    User login(LoginDTO loginDTO);

    @Insert("insert into user (name, phone, account, password, id_number, status, avatar,banned) VALUES " +
            "(#{name},#{phone},#{account},#{password},#{idNumber},#{status},#{avatar},#{banned})")
    void register(User  user);

    @Select("select * from user where id = #{id}")
    User getById(Long id);

    void update(User user);

    List<User> list(UserQueryDTO userQueryDTO);
}
